/**   
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-25 21:12:01  
 * Copyright (c) 2015- -版权所有     
 */

package com.joysuch.wwyt.bp.repository;

import java.util.List;

import com.joysuch.wwyt.bp.entity.BpAccidentCorrectiveMeasure;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

/**
 * BpAccidentCorrectiveMeasureDao
 *
 */
public interface BpAccidentCorrectiveMeasureDao extends JpaRepository<BpAccidentCorrectiveMeasure, Long>,
        QuerydslPredicateExecutor<BpAccidentCorrectiveMeasure> {
    public Page<BpAccidentCorrectiveMeasure> findAll(Specification<BpAccidentCorrectiveMeasure> spec,
            Pageable pageable);

    public BpAccidentCorrectiveMeasure save(BpAccidentCorrectiveMeasure bean);

    public void delete(BpAccidentCorrectiveMeasure bean);

    @Query("select newDiscovery from BpAccidentCorrectiveMeasure where id = ?1")
    public String getNewDiscoveryById(Long id);

    public List<BpAccidentCorrectiveMeasure> findByAccidentId(Long accidentId);

    public void deleteByAccidentId(Long id);

    @Modifying
    @Query("update BpAccidentCorrectiveMeasure set deleteFlag='1'  where accidentId = ?1 and id not in (?2)")
    public void deleteByAccidentIdExcludeIds(Long id, List<Long> existingIds);
}
